package com.example.test_demo.test;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;

public class test {

    public static void main(String[] args) {
        String s="UA-20212083";
        String[] split = s.split("-");
        System.out.println((Integer.valueOf(split[1].substring(0,8)) + 1));
//        BigDecimal decimal = new BigDecimal("-100");
//        System.out.println(decimal.multiply(new BigDecimal("5")));

//        List<user> users2 = new ArrayList<user>();
//        users2.add(new user("yanghua","nan"));
//
//        List<user> users = new ArrayList<user>();
//        users.add(new user("yanghua","nan"));
//        users.add(new user("liuqing","nv"));
//        Iterator<user> it = users.iterator();
//
//        users2.forEach(user1s ->{
//
//            while (it.hasNext()){
//                if (user1s.getName().equals(it.next().getName())){
//                    it.remove();
//                }
//            }
//        });
//        users.forEach(user ->{
//            System.out.println(user.getName());
//        });
       // System.out.println(test.parse("6666.10"));

//        String s[] ={"22","33"};
//        List<String> list = Arrays.asList(s);
//        for (int i = 0; i <list.size() ; i++) {
//            System.out.println(list.get(i));
//        }

//        String s="[\"20000\",\"BBL\",\"\\u00b1\",\"5\",\"%\",\"Mutual Agreement\",\"20000.000\"]";
//        String[] split = s.split(",");
//
//        System.out.println(split[0].substring(1)+split[1]);
//        BigDecimal multiply = new BigDecimal(1.1).multiply(new BigDecimal(1.1));
//        System.out.println(multiply);
//        String s ="20.387+3.7+0.12+1.415999+";
//        boolean b = s.endsWith("+");
//        System.out.println(s.substring(0,s.length()-1));
//        String s="";
//        DecimalFormat decimalFormat = setDecimalFormat(s);
//        System.out.println(decimalFormat.format(new BigDecimal(5)));
//        Date date =null;
//        try {
//             date = new SimpleDateFormat("yyyyMMdd").parse("20200425");
//        } catch (ParseException e) {
//            e.printStackTrace();
//        }
//        Calendar calendar = Calendar.getInstance();
//        calendar.setTime(date);
//        calendar.add(Calendar.DATE, -10);//
//        Date after15day = calendar.getTime();
//        DateFormat format = new SimpleDateFormat("yyyyMMdd");
//        String format1 = format.format(after15day);
//        String s="0000003303500";
//        String str1 = s.replaceAll("^(0+)", "");
//        System.out.println(str1);  // 1230
//        String S="[\"B-UUA-202011004\"]";
//        System.out.println(S.replace("[\"",""));
//        String s="file:/E:/test/test_excel/build/libs/test_excel-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/templates/exportdoc";
//        s=s.replace("libs/test_excel-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!/templates/exportdoc","tmpfiles");
//        System.out.println(s);
       // System.out.println(ToCH(51));

        //System.out.println("D.RECAP_DATE".split("\\.")[1]);

//        String s="[]";
//        String[] split = s.split(",");
//        System.out.println(split[0]);
//        int i=1;
//        int j=0;
//        if (i%3>0&&i%3<3)
//            j++;
//        j=j+i/3;
//        System.out.println(j);

//        Set<String> set = new TreeSet<>();
//        set.add("KFC");
//        set.add("KFC");
//        set.add("ABO");
//
//// 增强for循环
//        for (String string : set) {
//            System.out.println(string);
//        }
//        AtomicInteger k= new AtomicInteger();
//        System.out.println("319_325_"+k+"_1");
        //System.out.println("319_325_"+(8+4)+"_1");
//        int a = Integer.MAX_VALUE;
//        int b = -1;
//        System.out.println(a > b);
//        System.out.println(a - b>0);
//        String a="1164";
//
//        System.out.println( a.split(",")[0]);
        //System.out.println(addZeroForNum("3758",10));
        //System.out.println("".split("@")[0]);
//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd MMM yyyy", Locale.ENGLISH);
//        System.out.println(simpleDateFormat.format(new Date()));
//        DecimalFormat decimalFormat2 = new DecimalFormat(",##0.00");
//        System.out.println(decimalFormat2.format(new BigDecimal("43.211").multiply(new BigDecimal("1997875")).setScale(2, BigDecimal.ROUND_HALF_UP)));

       // System.out.println("youCRUDE OIL".endsWith("CRUDE OIL"));
        //new BigDecimal("33").divide(new BigDecimal("77"),2).multiply(new BigDecimal("66"));
//        System.out.println(BigDecimal.ZERO);
//        System.out.println(new BigDecimal("1").equals(BigDecimal.ZERO));
        //System.out.println(ToCH(1));


        //校验重名规则，返回code，比如0001-重名  0002-名称含有特殊字符
        //满足规则调用word生成接口，返回code，0000-成功，0008失败
        //前端根据返回的编码提示弹窗信息
        //System.out.println(new BigDecimal("5000000").compareTo(new BigDecimal("7000000"))==-1);

//        System.out.println(new SimpleDateFormat("dd MMMM yyyy", Locale.ENGLISH).format(new Date()));
//        System.out.println(new Date());

//        String beginTime=new String("2014-08-15 10:22:22");
//        String endTime=new String("2014-09-02 11:22:22");
//        System.out.println(beginTime.compareTo(endTime)<0);
          List<Apple> list = new ArrayList<Apple>();
            Apple apple = new Apple();
            apple.setAge("16");
            apple.setName("55");
            Apple apple1 = new Apple();
            apple1.setAge("99");
            apple1.setName("88");
            list.add(apple);
            list.add(apple1);
        for (int i = 0; i <list.size() ; i++) {
            Apple apple2 = list.get(i);
            if ("99".equals(apple2.getAge())){
                apple2.setName("77");
            }
        }
        for (int i = 0; i <list.size() ; i++) {
            System.out.println(list.get(i).getAge()+"===="+list.get(i).getName());
        }

    }

    public static String addZeroForNum(String str, int strLength) {
        int strLen = str.length();
        if (strLen < strLength) {
            while (strLen < strLength) {
                StringBuffer sb = new StringBuffer();
                sb.append("0").append(str);// 左补0
                // sb.append(str).append("0");//右补0
                str = sb.toString();
                strLen = str.length();
            }
        }
        return str;
    }


        public static String ToCH(int intInput) {
        String si = String.valueOf(intInput);
        String sd = "";
        if (si.length() == 1) // 個
        {
            sd += GetCH(intInput);
            return sd;
        } else if (si.length() == 2)// 十
        {
            if (si.substring(0, 1).equals("1"))
                sd += "十";
            else
                sd += (GetCH(intInput / 10) + "十");
            sd += ToCH(intInput % 10);
        } else if (si.length() == 3)// 百
        {
            sd += (GetCH(intInput / 100) + "百");
            if (String.valueOf(intInput % 100).length() < 2)
                sd += "零";
            sd += ToCH(intInput % 100);
        } else if (si.length() == 4)// 千
        {
            sd += (GetCH(intInput / 1000) + "千");
            if (String.valueOf(intInput % 1000).length() < 3)
                sd += "零";
            sd += ToCH(intInput % 1000);
        } else if (si.length() == 5)// 萬
        {
            sd += (GetCH(intInput / 10000) + "萬");
            if (String.valueOf(intInput % 10000).length() < 4)
                sd += "零";
            sd += ToCH(intInput % 10000);
        }

        return sd;
    }

    private static String GetCH(int input) {
        String sd = "";
        switch (input) {
            case 1:
                sd = "一";
                break;
            case 2:
                sd = "二";
                break;
            case 3:
                sd = "三";
                break;
            case 4:
                sd = "四";
                break;
            case 5:
                sd = "五";
                break;
            case 6:
                sd = "六";
                break;
            case 7:
                sd = "七";
                break;
            case 8:
                sd = "八";
                break;
            case 9:
                sd = "九";
                break;
            default:
                break;
        }
        return sd;
    }

    /**
     * DecimalFormat decimalFormat3 = new DecimalFormat(",##0.000");
     * 小数位数动态可变
     */
    private  static DecimalFormat setDecimalFormat(String str){

        String format=",##0.";
        if ("".equals(str)){
            return new DecimalFormat(",##0");
        }
        for (int i = 0; i <Integer.valueOf(str) ; i++) {
            format+="0";
        }
        if (format.endsWith(".")){
            format=format.substring(0,format.length()-1);
        }
        return new DecimalFormat(format);

    }
    //10以内的数字
    private static final String[] SINGLE_NUM_ARR = new String[] { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
    //十几的数字
    private static final String[] TEN_NUM_ARR = new String[] { "Ten", "Eleven", "Tweleve", "Thirteen", "Fourteen", "Fifteen", "Sixteen","Seventeen", "Eighteen", "Nineteen" };
    //整十的数字
    private static final String[] TEN_INTEGER_ARR = new String[] { "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };

    public static String parse(String x) {
        if(Double.parseDouble(x) <= 0){
            return "Zero Cents only";
        }
        int z = x.indexOf("."); // 取小数点位置
        String lstr = "", rstr = "";
        if (z > -1) { // 看是否有小数，如果有，则分别取左边和右边
            lstr = x.substring(0, z);
            rstr = x.substring(z + 1);
        } else // 否则就是全部
            lstr = x;

        String lstrrev = reverse(lstr); // 对左边的字串取反
        String[] a = new String[5]; // 定义5个字串变量来存放解析出来的叁位一组的字串

        switch (lstrrev.length() % 3) {
            case 1:
                lstrrev += "00";
                break;
            case 2:
                lstrrev += "0";
                break;
        }
        String lm = ""; // 用来存放转换後的整数部分
        for (int i = 0; i < lstrrev.length() / 3; i++) {
            a[i] = reverse(lstrrev.substring(3 * i, 3 * i + 3)); // 截取第一个叁位
            if (!a[i].equals("000")) { // 用来避免这种情况：1000000 = one million
                if (i != 0)
                    lm = transThree(a[i]) + " " + parseMore(String.valueOf(i)) + " " + lm; // 加:
                    // thousand、million、billion
                else
                    lm = transThree(a[i]); // 防止i=0时， 在多加两个空格.
            } else
                lm += transThree(a[i]);
        }

        String xs = ""; // 用来存放转换後小数部分
        if (z > -1){
            String transTwo =  transTwo(rstr);
            if(transTwo == null || "".equals(transTwo)){
                xs = "";
            }else{
                xs = "and " + transTwo + " Cents "; // 小数部分存在时转换小数
            }
        }
        return lm.trim() + " " + xs + "only";
    }

    private static String parseFirst(String s) {
        //String[] a = new String[] { "", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine" };
        return SINGLE_NUM_ARR[Integer.parseInt(s.substring(s.length() - 1))];
    }

    private static String parseTeen(String s) {
        //String[] a = new String[] { "Ten", "Eleven", "Tweleve", "Thirteen", "Fourteen", "Fifteen", "Sixteen","Seventeen", "Eighteen", "Nineteen" };
        return TEN_NUM_ARR[Integer.parseInt(s) - 10];
    }

    private static String parseTen(String s) {
        //String[] a = new String[] { "Ten", "Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety" };
        return TEN_INTEGER_ARR[Integer.parseInt(s.substring(0, 1)) - 1];
    }

    // 两位
    private static String transTwo(String s) {
        String value = "";
        // 判断位数
        if (s.length() > 2)
            s = s.substring(0, 2);
        else if (s.length() < 2)
            s = s + "0";

        if (s.startsWith("0")) // 07 - seven 是否小於10
            value = parseFirst(s);
        else if (s.startsWith("1")) // 17 seventeen 是否在10和20之间
            value = parseTeen(s);
        else if (s.endsWith("0")) // 是否在10与100之间的能被10整除的数
            value = parseTen(s);
        else
            value = parseTen(s) + " " + parseFirst(s);
        return value;
    }

    private static String parseMore(String s) {
        String[] a = new String[] { "", "Thousand", "Million", "Billion" };
        return a[Integer.parseInt(s)];
    }

    // 制作叁位的数
    // s.length = 3
    private static String transThree(String s) {
        String value = "";
        if (s.startsWith("0")) // 是否小於100
            value = transTwo(s.substring(1));
        else if (s.substring(1).equals("00")) // 是否被100整除
            value = parseFirst(s.substring(0, 1)) + " Hundred";
        else
            value = parseFirst(s.substring(0, 1)) + " Hundred and " + transTwo(s.substring(1));
        return value;
    }

    private static String reverse(String s) {
        char[] aChr = s.toCharArray();
        StringBuffer tmp = new StringBuffer();
        for (int i = aChr.length - 1; i >= 0; i--) {
            tmp.append(aChr[i]);
        }
        return tmp.toString();
    }




}
